﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    HQPad.Models.CharacterHeader header = (HQPad.Models.CharacterHeader)ViewBag.Header;
    HQPad.Models.SectAccessModel sects = (HQPad.Models.SectAccessModel)ViewBag.Sects;
    HQPad.Models.InvocationListModel invocations = (HQPad.Models.InvocationListModel)ViewBag.Invocations;
    string name = (string)ViewBag.CharacterName;
}

<script src="@Url.Content("~/Scripts/waiter.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/character.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/invocations.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/editable.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/messagelist.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $.fn.character({
            raceChangeActionUrl: '@Url.Action("SetRace")',
            classChangeActionUrl: '@Url.Action("SetClass")',
            headerContainerSelector: '.header-container',
            tableChangeCallback: null,
            guildChangeActionUrl: '@Url.Action("SetGuild")',
            guildChangeCallback: null,
            recordContainerSelector: '.record-container',
            addRecordItemUrl: '@Url.Action("AddRecord")',
            addRecordCallback: null,
            headerUrl: '@Url.Action("RefreshHeader")',
            headerRefreshedCallback: function () {
                $('.header-container .tooltipable[title]').tooltip();
            },
            updateNameUrl: '@Url.Action("UpdateName")',
            saveUrl: '@Url.Action("SaveCharacter")',
            silhouetteUrl: '@Url.Action("RefreshSilhouette")',
            silhouetteContainerSelector: '.silhouette-container',
            silhouetteRefreshedCallback: null
        });


        // set up generic tooltips.
        $('.tooltipable').tooltip();
        /*
        // set up named tooltips.
        $('.named-tooltip').each(function () {
        var tipId = $(this).attr('tip');

        $(this).tooltip({ tip: '#tooltip-' + tipId });
        });
        */

        $.fn.invocations({
            updateInvocationUrl: '@Url.Action("UpdateInvocation")',
            invocationUpdatedCallback: function (selectedElement, selected) {
                $.fn.invocations('refreshSects');

                if (selectedElement) {
                    if (selected === true && !$(selectedElement).hasClass('invocation-known'))
                        $(selectedElement).addClass('invocation-known');
                    else if (!selected === true && $(selectedElement).hasClass('invocation-known'))
                        $(selectedElement).removeClass('invocation-known');
                }
            },
            refreshInvocationsUrl: '@Url.Action("RefreshInvocations")',
            invocationsContainer: '.invocations-container',
            invocationsCallback: null,
            sectsUrl: '@Url.Action("RefreshSects")',
            sectsContainerSelector: '.sects-container',
            sectlsRefreshedCallback: null,
            knownInvocationLimits: @Html.Raw(sects.Status.BuildJsonSectStatusArray())
        });

        setupMessageList(); // defined in global.
    });
</script>

<h1 class="with-control-box character-name">@Html.Raw(name)</h1>
<div class="message-box"></div>

<section class="full-width header-container">
@Html.Partial("~/Views/Shared/Character/CharacterHeader.cshtml", header)
</section>

@Html.Partial("~/Views/Shared/Character/CharacterTabs.cshtml", header)

<section class="content flush-with-nav flat-top invocations-container">
@Html.Partial("~/Views/Shared/Character/CharacterInvocations.cshtml", invocations)
</section>

<section class="sidebar flush-with-nav">
    <div class="sects-container">
        @Html.Partial("~/Views/Shared/Character/CharacterSects.cshtml", sects)
    </div>
</section>
